package com.fourth.controller;

import com.fourth.dao.BusinessDao;
import com.fourth.dao.ExamineDao;
import com.fourth.service.ExamineService;
import com.fourth.vo.ExamineVo;
import com.ljx.entity.BusinessInfo;
import com.ljx.entity.Examine;
import com.ljx.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: 商家审查审核
 * @date 2023/2/27
 */
@RestController
@RequestMapping("/merchant")
public class ExamineController {

    @Autowired
    private ExamineService examineService;

    @Autowired(required = false)
    private BusinessDao auditDao;

    @Autowired(required = false)
    private ExamineDao examineDao;
    /**
     * 审查审核查全表
     * @param currentPage
     * @param pageSize
     * @param startTime
     * @param endTime
     * @return
     */
    @RequestMapping("/examine")
    public Result selectExamine(@RequestParam(defaultValue = "1" ) Integer currentPage,@RequestParam(defaultValue = "5" )Integer pageSize,String startTime,String endTime){
        Result select = examineService.examineSelect(currentPage, pageSize, startTime, endTime);
        return new Result(2000,"查询成功",select);
    }

    /**
     * 查询所有店铺
     * @return
     */
    @RequestMapping("insertExamine")
    public Result insertExamine(){
        List<BusinessInfo> businessInfos = auditDao.selectAllBusiness();
        return new Result(2000,"查询成功",businessInfos);
    }

    /**
     * 删除审查表中对应ID 数据
     * @param id
     * @return
     */
    @RequestMapping("/deleteExamine/{id}")
    public Result deleteExamine(@PathVariable("id")  String id){
        int deleteById = examineDao.deleteById(id);
        return new Result(2000,"删除成功",deleteById);
    }

    /**
     * 审查表接收和返回数据
     * @param examine
     * @return
     * 备注：待使用
     */
    @RequestMapping("/addExamine")
    public Result addExamine(Examine examine){
        Result addTo = examineService.insertExamine(examine);
        return new Result(2000,"删除成功",addTo);
    }

    /**
     * 修改表中店铺对应的状态和停业原因
     * @param
     * @return
     */
    @RequestMapping("/updateById")
    public Result updateById( @RequestBody ExamineVo examineVo){

        Result result = examineService.updateTableField(examineVo);
        return new Result(2000,"修改成功",result);
    }

}
